package com.hospital.dictionary.module.controller;


import com.hospital.common.core.result.SuccessTip;
import com.hospital.common.core.result.Tip;
import com.hospital.dictionary.module.controller.base.BaseController;
import com.hospital.dictionary.module.entity.ClinicItemGuideKey;
import com.hospital.dictionary.module.service.ClinicItemGuideKeyService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * ÕïÁÆÏîÄ¿Ö¸ÒýÐÅÏ¢Ä£°åÅäÖÃ 前端控制器
 * </p>
 *
 * @author lvyao
 * @since 2024-01-10
 */
@RestController
@RequestMapping("/module/clinicItemGuideKey")
public class ClinicItemGuideKeyController extends BaseController<ClinicItemGuideKey, ClinicItemGuideKeyService> {
    @Resource
    private ClinicItemGuideKeyService clinicItemGuideKeyService;
    @Override
    public Tip updateDto(@RequestBody @Valid ClinicItemGuideKey object){
        ClinicItemGuideKey clinicItemGuideKey = clinicItemGuideKeyService.getById(object.getOnekey());
        boolean result =true;
        if (object.getSortNo().equals(clinicItemGuideKey.getSortNo())){
             result = clinicItemGuideKeyService.updateById(object);
        }else {
            result=clinicItemGuideKeyService.updateAll(object,clinicItemGuideKey.getSortNo());
        }

        return new SuccessTip(result);
    }
}

